home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-05-26 | 6.1 KB | 213 lines | [TEXT/MPS ] |
- // Copyright ©1994 Apple Computer, Inc.
- // Author: John Powers
- // Date: 13-Mar-94
-
- // UAppMo.h
- // Header for our main program for MoGuide.
- // Contains all our derived classes and our new classes.
-
- #ifndef __UAPPMO__
- #define __UAPPMO__ // #endif __UAPPMO__ is at end of this file
-
- // Most of the includes are covered in UApp.h
-
- #include <GestaltEqu.h> // Gestalt
- #include <Menus.h>
-
- #ifndef __UAPP__
- #include "UApp.h"
- #endif
-
- #ifndef __UDOCMO__
- #include "UDocMo.h"
- #endif
-
- // Constants (also see UAppShared.h).
-
- #define override virtual
-
-
- #define FRONT_WINDOW ((WindowPtr) (-1L))
-
- // ------------------------------------------------------------------------
-
-
- // Forward references
-
- class TAppMo;
- class TDoc;
- class TDocClip;
- class TDocArt;
- class TDocFB;
-
- // ------------------------------------------------------------------------
- // TTypeStr
- // Makes a string from a type.
-
- typedef union {
- OSType type;
- unsigned char ch[4];
- } TypeToChar, CharToType;
-
- class TTypeStr
- {
- private:
- unsigned char fString[5];
- protected:
- public:
- TTypeStr(OSType theType); // Constructor
- StringPtr String();
- };
-
- // ------------------------------------------------------------------------
- // TFeedback
- // Flashes a 4-character string for a predefined interval.
- //
- // Instantiate a TFeedback object.
- // Init the object with the application object and the TFeedback index.
- // SetDoc when the feedback document is created.
- // SetDoc with nil when the feedback document is deleted.
- // GetBeep and SetBeep as desired (default is false, no beep.)
- // SetInterval only if the default (kIntervalShow) is not desired.
- // Set a interval of 0, for an infinite interval.
- // SetFlash with the data to feedback. Pass OSType, Ptr, or Str255.
- // DoIdle in the Idle loop (does the drawing of the feedback data.)
- //
- // Time is measured in ticks.
- //
- class TFeedback
- {
- private:
- enum {
- kIntervalShow = 120,
- kPaint = patCopy,
- kErase = patBic
- };
- short fWhichData; // Index for display location of data
- long fShowTime; // Last time data was shown.
- long fInterval; // Time interval to show data before erasing.
- OSType fCurrent; // Current data to show
- OSType fPrevious; // Data previously shown
- Boolean fShow; // true if we want to show data
- Boolean fBeep; // true if we want a beep
- TAppMo* fOurApp; // Collaborator
- TDocFB* fDocFB; // Feedback window collaborator
- virtual void Draw(OSType toDraw, short mode);
- virtual void Show();
- protected:
- public:
- TFeedback(); // Constructor
- virtual ~TFeedback(); // Destructor
- virtual void DoIdle();
- virtual Boolean GetBeep();
- virtual void SetBeep(Boolean wantBeep);
- virtual void SetFlash(OSType theFlash);
- virtual void SetFlash(Ptr theFlash);
- virtual void SetFlash(Str255 theFlash);
- virtual void SetDoc(TDocFB* doc) {this->fDocFB = doc;}
- virtual void SetInterval(short interval) {this->fInterval = interval;}
- virtual void Init(TAppMo* theApp, short whichData);
- };
-
- // ------------------------------------------------------------------------
- // TContext
- // Completely encapsulates all the context checking from Apple Guide.
-
- class TContext
- {
- private:
- enum {
- kContextHandlerCnt = 3,
- kAEIdContextCollision = 'WiYe',
- kAEIdContextBeep = 'WiYf',
- kAEIdContextWindow = 'WiYg'
- };
- struct ContextCheck {
- AEEventID eventID;
- AGContextRefNum refNum;
- };
- short fHandlerCnt; // No.of handlers
- ContextCheck fContext[kContextHandlerCnt]; // Context
- protected:
- public:
- TContext(); // Constructor
- virtual ~TContext(); // Destructor
- virtual OSErr Install(long appObj);
- virtual OSErr Remove();
- static pascal OSErr ReplyToContext(Ptr pInput,
- Size inputDataSize,
- Ptr *ppOutput,
- Size *pOutputDataSize,
- AGAppInfoHdl hAppInfo);
- };
-
- // ------------------------------------------------------------------------
- // Derive our application class from the application base class.
- // Add the About dialog, initialization, and a menu.
-
- class TAppMo : public TApp
- {
- friend class TContext; // To give access to our private parts.
- private:
- enum {
- // Custom event class and id's
- // Context events are in TContext.
- kAEClassCustom = 'MoHC',
- kAEIdCloseDocArt = 'MoCa',
- kAEIdShowDocArt = 'MoSa',
- kAEIdCloseDocFB = 'MoCf',
- kAEIdShowDocFB = 'MoSf',
- kAEIdReset = 'MoRs',
- kAEIdShuffle = 'MoSh',
- kAEIdQuitApp = 'MoQa',
- kAEIdWaitCollision = 'MoAw',
- kAEIdIgnoreCollision = 'MoAi',
- kAEIdAdvance = 'MoAa',
- // Maximum cycles between status updates.
- kMaxStatusUpdateCnt = 100
- };
- AGCoachRefNum fCoachRefNum; // Coach handler
- TContext* fContext; // Context handler object
- Handle fhFileList; // Handle of FSSpecs for guide files.
- short fFileCount; // Number of guide files.
- Boolean fBeepReturn; // Reply to kAEIdContextBeep query.
- Boolean fOkayAdvance; // True if a panel advance is okay.
- short fLastMiscIndex; // Last index for FBMisc string.
- short fLastStatusCnt; // Last status update counter.
- TFeedback* fFBContext; // Context feedback
- TFeedback* fFBCoach; // Coach feedback
- TFeedback* fFBEvent; // Event feedback
- TFeedback* fFBMisc; // Miscellaneous feedback
- TDocArt* fDocArt; // Our current art document window
- TDocFB* fDocFB; // Feedback document window
- // New functions.
- virtual void CheckFrontWindow();
- protected:
- // New functions.
- virtual void AddGuideFiles();
- static pascal OSErr ReplyToCoach(Rect* pItemRect,
- Ptr pName,
- long refCon);
- virtual void ShowArt();
- virtual void ShowFeedback();
- // Overrides
- override void AdjustMenus();
- override void DoGoAway();
- override void DoIdle();
- override void DoMenuCommand(short menuID, short menuItem);
- override OSErr Start();
- public:
- TAppMo(); // Constructor
- // New functions.
- virtual void DoAdvance();
- virtual TDocArt* GetDocArt() {return this->fDocArt;}
- static pascal OSErr HandleAECustom(AppleEvent& theAppleEvent,
- AppleEvent& theReply,
- long refCon);
- virtual void SetOkayAdvance(Boolean isOkay) {this->fOkayAdvance=isOkay;}
- // Overrides
- override OSErr Init();
- override void Quit();
- };
-
- #endif __UAPPMO__